import { RouteRecordRaw } from "vue-router";
import ACCESS_ENUM from "@/access/accessEnum";
import UserLayout from "@/layouts/UserLayout.vue";
import UserLoginView from "@/views/user/UserLoginView.vue";
import UserRegisterView from "@/views/user/UserRegisterView.vue";
import AddQuestionView from "@/views/question/AddQuestionView.vue";
import ManageQuestionView from "@/views/question/ManageQuestionView.vue";
import QuestionsView from "@/views/question/QuestionsView.vue";
import QuestionSubmitView from "@/views/question/QuestionSubmitView.vue";
import ViewQuestionView from "@/views/question/ViewQuestionView.vue";
import ContestListView from "@/views/contest/ContestListView.vue";
import ContestDetailView from "@/views/contest/ContestDetailView.vue";
import ContestProblemView from "@/views/contest/ContestProblemView.vue";
import ContestManageView from "@/views/contest/ContestManageView.vue";

export const routes: Array<RouteRecordRaw> = [
  {
    path: "/user",
    name: "用户",
    meta: {
      hideInMenu: true,
    },
    component: UserLayout,
    children: [
      {
        path: "/user/login",
        name: "UserLogin",
        component: UserLoginView,
      },
      {
        path: "/user/register",
        name: "UserRegister",
        component: UserRegisterView,
      },
    ],
  },
  {
    path: "/",
    name: "Questions",
    component: QuestionsView,
  },
  {
    path: "/question_submit",
    name: "QuestionSubmit",
    component: QuestionSubmitView,
  },
  {
    path: "/view/question/:id",
    name: "Exercise",
    component: ViewQuestionView,
    props: true,
    meta: {
      access: ACCESS_ENUM.USER,
      hideInMenu: true,
    },
  },
  {
    path: "/check/question/:id",
    name: "Check",
    component: ViewQuestionView,
    props: true,
    meta: {
      access: ACCESS_ENUM.USER,
      hideInMenu: true,
    },
  },
  {
    path: "/add/question",
    name: "AddQuestion",
    component: AddQuestionView,
    meta: {
      access: ACCESS_ENUM.ADMIN,
    },
  },
  {
    path: "/manage/question",
    name: "ManageQuestion",
    component: ManageQuestionView,
    meta: {
      access: ACCESS_ENUM.ADMIN,
    },
  },
  {
    path: "/update/question",
    name: "UpdateQuestion",
    component: AddQuestionView,
    meta: {
      access: ACCESS_ENUM.ADMIN,
      hideInMenu: true,
    },
  },
  {
    path: "/contests",
    name: "Contests",
    component: ContestListView,
    meta: {
      access: ACCESS_ENUM.USER,
    },
  },
  {
    path: "/contest/:id",
    name: "ContestDetail",
    component: ContestDetailView,
    props: true,
    meta: {
      access: ACCESS_ENUM.USER,
      hideInMenu: true,
    },
  },
  {
    path: "/contest/:contestId/problem/:problemId",
    name: "ContestProblem",
    component: ContestProblemView,
    props: true,
    meta: {
      access: ACCESS_ENUM.USER,
      hideInMenu: true,
    },
  },
  {
    path: "/manage/contests",
    name: "ContestManage",
    component: ContestManageView,
    meta: {
      access: ACCESS_ENUM.ADMIN,
    },
  },
];
